package com.seeyon.apps.util;

import com.seeyon.apps.commonExt.domain.Cap4Where;
import com.seeyon.apps.commonExt.util.CAP4FormDataManagerExt;
import com.seeyon.cap4.form.bean.*;
import com.seeyon.cap4.form.exception.FormException;
import com.seeyon.cap4.form.service.CAP4FormManager;
import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.common.ctpenum.dao.cache.CtpEnumCache;
import com.seeyon.ctp.common.ctpenum.dao.cache.CtpEnumItemCache;
import com.seeyon.ctp.common.ctpenumnew.Constants;
import com.seeyon.ctp.common.ctpenumnew.manager.EnumManager;
import com.seeyon.ctp.common.exceptions.BusinessException;
import com.seeyon.ctp.common.po.ctpenumnew.CtpEnumBean;
import com.seeyon.ctp.common.po.ctpenumnew.CtpEnumItem;
import com.seeyon.ctp.util.FlipInfo;

import cn.hutool.core.lang.Assert;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @description:
 * @author: huangjin
 * @time: 2025/3/23 08:21
 */
public class EnumUtilExt {

    private static EnumManager enumManager;

    private static CtpEnumCache ctpEnumCache;

    private static CtpEnumItemCache ctpEnumItemCache;

    private static CAP4FormManager cap4FormManager;


    static {
        enumManager = (EnumManager) AppContext.getBean("enumManagerNew");
        ctpEnumCache = (CtpEnumCache) AppContext.getBean("ctpEnumCache");
        ctpEnumItemCache = (CtpEnumItemCache) AppContext.getBean("ctpEnumItemCache");
        cap4FormManager = (CAP4FormManager) AppContext.getBean("cap4FormManager");
    }

    public static class EnumFieldNotFoundException extends RuntimeException {

        public EnumFieldNotFoundException() {
        }

        public EnumFieldNotFoundException(String message) {
            super(message);
        }

        public EnumFieldNotFoundException(String message, Throwable cause) {
            super(message, cause);
        }

        public EnumFieldNotFoundException(Throwable cause) {
            super(cause);
        }

        public EnumFieldNotFoundException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
            super(message, cause, enableSuppression, writableStackTrace);
        }
    }

    public static class EnumFieldNotDefineException extends RuntimeException {

        public EnumFieldNotDefineException() {
        }

        public EnumFieldNotDefineException(String message) {
            super(message);
        }

        public EnumFieldNotDefineException(String message, Throwable cause) {
            super(message, cause);
        }

        public EnumFieldNotDefineException(Throwable cause) {
            super(cause);
        }

        public EnumFieldNotDefineException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
            super(message, cause, enableSuppression, writableStackTrace);
        }
    }

    public static void preLoad() {
        if (enumManager == null) {
            enumManager = (EnumManager) AppContext.getBean("enumManagerNew");
        }
        if (ctpEnumCache == null) {
            ctpEnumCache = (CtpEnumCache) AppContext.getBean("ctpEnumCache");
        }
        if (ctpEnumItemCache == null) {
            ctpEnumItemCache = (CtpEnumItemCache) AppContext.getBean("ctpEnumItemCache");
        }
    }

    /**
     * @description:
     * @author: huangjin
     * @time: 2025/3/28 08:54
     */
    public static enum EnumType {
        // 公共枚举
        PUBLIC_ENUMS("PUBLIC_ENUMS"),
        // 单位枚举
        UNIT_ENUMS("UNIT_ENUMS"),
        // 业务枚举
        BUSINESS_ENUMS("BUSINESS_ENUMS");


        EnumType(String enumName) {

        }

        public static EnumType toEnum(String type) {
            if (StringUtils.isBlank(type)) {
                return null;
            }
            for (EnumType enumType : EnumType.values()) {
                if (enumType.name().equals(type)) {
                    return enumType;
                }
            }
            throw new FormException("未找到该枚举类型");
        }

    }


    /**
     * 根据枚举项id获取枚举项
     *
     * @param enumItemId
     * @return
     * @throws BusinessException
     * @description:
     * @author: huangjin
     * @time: 2025/3/24 16:30
     */
    public static CtpEnumItem getEnumItemByEnumItemId(Long enumItemId) throws BusinessException {
        if (null == enumItemId) {
            return null;
        }
        preLoad();
        CtpEnumItem item = enumManager.getEnumItem(enumItemId);
        Assert.notNull(item, "{} 枚举项不存在", enumItemId);
        return item;
    }

    /**
     * 根据枚举项id获取枚举项值
     *
     * @param enumItemId
     * @return
     * @throws BusinessException
     * @description:
     * @author: huangjin
     * @time: 2025/3/24 16:30
     */
    public static String getEnumItemValByEnumItemId(Long enumItemId, String defaultVal) throws BusinessException {
        preLoad();
        CtpEnumItem item = enumManager.getEnumItem(enumItemId);
        return item == null ? defaultVal : item.getValue();
    }

    /**
     * 根据枚举项id获取枚举项值
     *
     * @param enumItemId
     * @return
     * @throws BusinessException
     * @description:
     * @author: huangjin
     * @time: 2025/3/24 16:30
     */
    public static String getEnumItemValByEnumItemId(Long enumItemId) throws BusinessException {
       return getEnumItemValByEnumItemId(enumItemId, null);
    }

    /**
     * 根据枚举id和枚举值获取枚举项
     *
     * @param enumId
     * @param enumItemValue
     * @return
     * @description:
     * @author: huangjin
     * @time: 2025/3/23 09:04
     */
    public static CtpEnumItem getEnumItemByEnumIdAndEnumItemValue(Long enumId, String enumItemValue) {
        preLoad();
        return enumManager.getEnumItem(enumId, enumItemValue);
    }

    /**
     * 根据枚举id和枚举名称获取枚举项
     *
     * @param enumId
     * @param enumItemName
     * @return
     * @description:
     * @author: huangjin
     * @time: 2025/3/23 09:04
     */
    public static CtpEnumItem getEnumItemByEnumIdAndEnumItemName(Long enumId, String enumItemName) {
        preLoad();
        List<CtpEnumItem> enumItemList = enumManager.getAllItemListByEnumId(enumId);
        List<CtpEnumItem> matchEnumItemList = enumItemList.stream().filter(ctpEnumItem -> enumItemName.equals(ctpEnumItem.getShowvalue())).collect(Collectors.toList());
        Assert.notEmpty(matchEnumItemList, "{},{} 枚举项不存在", enumId, enumItemName);
        Assert.isTrue(matchEnumItemList.size() == 1, "{},{} 枚举项不唯一", enumId, enumItemName);
        return matchEnumItemList.get(0);
    }


    /**
     * 根据枚举名称和枚举项名称获取唯一的枚举项
     *
     * @param enumName
     * @param itemName
     * @return
     * @description:
     * @author: huangjin
     * @time: 2025/3/23 10:15
     */
    public static CtpEnumItem getEnumItemByEnumNameAndItemName(String enumName, String itemName) {
        preLoad();
        // 公共枚举 和单位枚举
        List<CtpEnumBean> ctpEnumBeanList = ctpEnumCache.findByType(CtpEnumCache.CacheType.PUBLIC_AND_UNIT_ENUMS);
        List<CtpEnumBean> matchEnumBeanList = ctpEnumBeanList.stream().filter(ctpEnumBean -> enumName.equals(ctpEnumBean.getEnumname())).collect(Collectors.toList());
        if (CollectionUtils.isNotEmpty(matchEnumBeanList)) {
            // 排序，公共枚举排前面其次按照排序字段排序
            matchEnumBeanList.sort(((o1, o2) -> {
                if (null == o1.getOrgAccountId() && null != o2.getEnumtype()) {
                    return -1;
                }
                return o1.getSort() - o2.getSort();
            }));
            for (CtpEnumBean ctpEnumBean : matchEnumBeanList) {
                if (enumName.equals(ctpEnumBean.getEnumname())) {
                    return getEnumItemByEnumIdAndEnumItemName(ctpEnumBean.getId(), itemName);
                }
            }
        }

        // 业务枚举
        ctpEnumBeanList = ctpEnumCache.findByType(CtpEnumCache.CacheType.BUSINESS_ENUMS);
        matchEnumBeanList = ctpEnumBeanList.stream().filter(ctpEnumBean -> enumName.equals(ctpEnumBean.getEnumname())).collect(Collectors.toList());
        if (CollectionUtils.isNotEmpty(matchEnumBeanList)) {
            for (CtpEnumBean ctpEnumBean : matchEnumBeanList) {
                if (enumName.equals(ctpEnumBean.getEnumname())) {
                    return getEnumItemByEnumIdAndEnumItemName(ctpEnumBean.getId(), itemName);
                }
            }
        }
        throw new FormException(String.format("%s,%s 枚举项不存在", enumName, itemName));
    }


    /**
     * 根据枚举类型、枚举分类名称和枚举名称获取枚举项集合
     *
     * @param enumName
     * @return
     * @description:
     * @author: huangjin
     * @time: 2025/3/28 08:46
     */
    public static List<CtpEnumItem> getEnumItemsByCategoryNameEnumNameAndItemName(EnumType enumTypeExt, String categoryName, String enumName) {
        preLoad();
        List<CtpEnumBean> ctpEnumBeanList = getEnumBeanByCategoryNameEnumName(enumTypeExt, categoryName, enumName);
        try {
            return enumManager.getEmumItemByEmumId(ctpEnumBeanList.get(0).getId());
        } catch (BusinessException e) {
            throw new FormException(String.format("%s 枚举异常", enumName));
        }
    }


    /**
     * 根据枚举类型、枚举名称、枚举项名称查找根节点的枚举项
     *
     * @param enumTypeExt
     * @param enumName
     * @param itemName
     * @return
     * @description:
     * @author: huangjin
     * @time: 2025/3/28 10:24
     */
    public static CtpEnumItem getEnumItemByEnumNameAndItemName(EnumType enumTypeExt, String enumName, String itemName) {
        preLoad();
        return getEnumItemByCategoryNameEnumNameAndItemName(enumTypeExt, null, enumName, itemName);
    }

    /**
     * 根据枚举类型、枚举分类、枚举名称、枚举项名称查找枚举项
     *
     * @param enumTypeExt
     * @param categoryName
     * @param enumName
     * @param itemName
     * @return
     * @description:
     * @author: huangjin
     * @time: 2025/3/28 10:24
     */
    public static CtpEnumItem getEnumItemByCategoryNameEnumNameAndItemName(EnumType enumTypeExt, String categoryName, String enumName, String itemName) {
        preLoad();
        List<CtpEnumBean> ctpEnumBeanList = getEnumBeanByCategoryNameEnumName(enumTypeExt, categoryName, enumName);
        return getEnumItemByEnumIdAndEnumItemName(ctpEnumBeanList.get(0).getId(), itemName);
    }

    /**
     * 根据枚举类型、枚举分类名称和枚举名称获取枚举项集合
     *
     * @param enumName
     * @return
     * @description:
     * @author: huangjin
     * @time: 2025/3/28 08:46
     */
    public static List<CtpEnumBean> getEnumBeanByCategoryNameEnumName(EnumType enumTypeExt, String categoryName, String enumName) {
        preLoad();
        // 是否根路径
        boolean checkRoot = StringUtils.isBlank(categoryName);
        List<CtpEnumBean> ctpEnumBeanList = null;
        List<CtpEnumBean> categoryEnumBeanList;

        // 公共枚举
        if (enumTypeExt == EnumType.PUBLIC_ENUMS) {
            ctpEnumBeanList = ctpEnumCache.findByType(CtpEnumCache.CacheType.PUBLIC_AND_UNIT_ENUMS);
            ctpEnumBeanList = ctpEnumBeanList.stream().filter(item -> item.getOrgAccountId() == null).collect(Collectors.toList());

        }

        // 单位枚举
        else if (enumTypeExt == EnumType.UNIT_ENUMS) {
            ctpEnumBeanList = ctpEnumCache.findByType(CtpEnumCache.CacheType.PUBLIC_AND_UNIT_ENUMS);
            ctpEnumBeanList = ctpEnumBeanList.stream().filter(item -> item.getOrgAccountId() != null).collect(Collectors.toList());
        }

        // 业务枚举
        else if (enumTypeExt == EnumType.BUSINESS_ENUMS) {
            ctpEnumBeanList = ctpEnumCache.findByType(CtpEnumCache.CacheType.BUSINESS_ENUMS);
            ctpEnumBeanList = ctpEnumBeanList.stream().filter(item -> item.getOrgAccountId() != null).collect(Collectors.toList());
        } else {
            throw new FormException("EnumTypeExt 不支持");
        }

        if (checkRoot) {
            categoryEnumBeanList = null;
            ctpEnumBeanList = ctpEnumBeanList.stream().filter(ctpEnumBean -> enumName.equals(ctpEnumBean.getEnumname()) && Objects.equals(ctpEnumBean.getParentId(), Constants.CACHE_ROOT_ID)).collect(Collectors.toList());
            Assert.isTrue(CollectionUtils.isNotEmpty(ctpEnumBeanList), "{} 枚举不存在", enumName);
            Assert.isTrue(ctpEnumBeanList.size() == 1, "{} 枚举不唯一", enumName);

        } else {
            categoryEnumBeanList = ctpEnumBeanList.stream().filter(item -> categoryName.equals(item.getEnumname())).collect(Collectors.toList());
            Assert.isTrue(CollectionUtils.isNotEmpty(categoryEnumBeanList), "{} 枚举分类不存在", categoryName);
            Assert.isTrue(categoryEnumBeanList.size() == 1, "{} 枚举分类不唯一", categoryName);
            ctpEnumBeanList = ctpEnumBeanList.stream()
                    .filter(ctpEnumBean -> enumName.equals(ctpEnumBean.getEnumname())
                            && Objects.equals(categoryEnumBeanList.get(0).getId(), ctpEnumBean.getParentId()))
                    .collect(Collectors.toList());
            Assert.isTrue(CollectionUtils.isNotEmpty(ctpEnumBeanList), "{} 枚举不存在", enumName);
            Assert.isTrue(ctpEnumBeanList.size() == 1, "{} 枚举不唯一", enumName);

        }
        return ctpEnumBeanList;
    }


    /**
     * 根据表单编码获取表单枚举项集合
     *
     * @param formBean
     * @param fieldDisplay
     * @return
     * @description:
     * @author: huangjin
     * @time: 2025/3/28 11:40
     */
    public static List<CtpEnumItem> getEnumItemsByFormCodeAndFieldDisplay(FormBean formBean, String fieldDisplay) throws BusinessException {
        Assert.notBlank(fieldDisplay, "数据域字段名不能为空");
        preLoad();

        FormFieldBean formFieldBean = formBean.getFieldBeanByDisplay(fieldDisplay);
        if (null == formFieldBean) {
            List<FormTableBean> subTableBeans = formBean.getSubTableBean();
            Assert.notEmpty(subTableBeans, "{},{}枚举不存在", formBean.getFormName(), fieldDisplay);
            for (FormTableBean subTableBean : subTableBeans) {
                formFieldBean = subTableBean.getFieldBeanByDisplay(fieldDisplay);
                if (null == formFieldBean) {
                    continue;
                }
                break;
            }
        }
        if (null == formFieldBean) {
            throw new EnumFieldNotDefineException(String.format("【%s】 表单中未定义字段【%s】", formBean.getFormName(), fieldDisplay));
        }
        long enumId = formFieldBean.getEnumId();
        if (enumId == 0) {
            throw new EnumFieldNotFoundException(fieldDisplay + "不是枚举字段");
        }
        return enumManager.getEmumItemByEmumId(enumId);
    }
    public static String getEnumItemIdByFormCodeAndFieldDisplayAndEnumItemName(String formCode, String fieldDisplay, String enumItemName) {
        return getEnumItemIdByFormCodeAndFieldDisplayAndEnumItemName(formCode, fieldDisplay, enumItemName, enumItemName);
    }
    public static String getEnumItemIdByFormCodeAndFieldDisplayAndEnumItemName(String formCode, String fieldDisplay, String enumItemName, String defaultVal) {
        if (null == enumItemName) {
            return defaultVal;
        }
        try {
            CtpEnumItem enumItem = getEnumItemByFormCodeAndFieldDisplayAndEnumItemName(formCode, fieldDisplay, enumItemName);
            return String.valueOf(enumItem.getId());
        } catch (EnumFieldNotDefineException | EnumFieldNotFoundException e) {
            return defaultVal;
        }
    }

    public static String getEnumItemValByFormCodeAndFieldDisplayAndEnumItemName(String formCode, String fieldDisplay, String enumItemName) {
        return getEnumItemValByFormCodeAndFieldDisplayAndEnumItemName(formCode, fieldDisplay, enumItemName, enumItemName);
    }

    public static String getEnumItemLabelByFormCodeAndFieldDisplayAndEnumItemName(String formCode, String fieldDisplay, String enumItemName, String defaultVal) {
        try {
            CtpEnumItem enumItem = getEnumItemByFormCodeAndFieldDisplayAndEnumItemName(formCode, fieldDisplay, enumItemName);
            return String.valueOf(enumItem.getLabel());
        } catch (EnumFieldNotFoundException | EnumFieldNotDefineException e) {
            return defaultVal;
        }
    }

    public static String getEnumItemLabelByFormCodeAndFieldDisplayAndEnumItemName(String formCode, String fieldDisplay, String enumItemName) {
        return getEnumItemValByFormCodeAndFieldDisplayAndEnumItemName(formCode, fieldDisplay, enumItemName, enumItemName);
    }
    public static String getEnumItemValByFormCodeAndFieldDisplayAndEnumItemName(String formCode, String fieldDisplay, String enumItemName, String defaultVal) {
        try {
            CtpEnumItem enumItem = getEnumItemByFormCodeAndFieldDisplayAndEnumItemName(formCode, fieldDisplay, enumItemName);
            return enumItem.getValue();
        } catch (EnumFieldNotFoundException | EnumFieldNotDefineException e) {
            return defaultVal;
        }
    }

    /**
     * 根据表单编码和枚举项名称和枚举中文值获取表单枚举项
     *
     * @param formCode
     * @param fieldDisplay
     * @param enumItemName
     * @return
     * @description:
     * @author: huangjin
     * @time: 2025/3/28 11:41
     */
    public static CtpEnumItem getEnumItemByFormCodeAndFieldDisplayAndEnumItemName(String formCode, String fieldDisplay, String enumItemName) {
        Assert.notBlank(enumItemName, "枚举项名称不能为空");
        preLoad();
        FormBean formBean = null;
        try {
            formBean = cap4FormManager.getFormByFormCode(formCode);
            Assert.notNull(formBean, "{} 表单定义为空", formCode);
            return getEnumItemByFormBeanAndFieldDisplayAndEnumItemName(formBean, fieldDisplay, enumItemName);
        } catch (EnumFieldNotFoundException e) {
            throw new EnumFieldNotFoundException(e.getMessage());
        }catch (EnumFieldNotDefineException e) {
            throw new EnumFieldNotDefineException(e.getMessage());
        }catch (Exception e) {
            if (formBean == null) {
                throw new FormException(String.format("枚举异常: 【%s】",  e.getMessage()));
            }else {
                throw new FormException(String.format("表单【%s】枚举异常: 【%s】", formBean.getFormName(), e.getMessage()));
            }
        }
    }

    public static CtpEnumItem getEnumItemByFormBeanAndFieldDisplayAndEnumItemName(FormBean formBean, String fieldDisplay, String enumItemName) {
        Assert.notBlank(enumItemName, "枚举项名称不能为空");
        preLoad();
        try {
            List<CtpEnumItem> enumItemList = getEnumItemsByFormCodeAndFieldDisplay(formBean, fieldDisplay);
            List<CtpEnumItem> matchEnumItemList = enumItemList.stream().filter(ctpEnumItem -> enumItemName.equals(ctpEnumItem.getShowvalue())).collect(Collectors.toList());
            Assert.notEmpty(matchEnumItemList, "{},{} 枚举项不存在", fieldDisplay, enumItemName);
            Assert.isTrue(matchEnumItemList.size() == 1, "{},{} 枚举项不唯一", fieldDisplay, enumItemName);
            return matchEnumItemList.get(0);
        } catch (EnumFieldNotFoundException e) {
            throw new EnumFieldNotFoundException(e.getMessage());
        }catch (EnumFieldNotDefineException e) {
            throw new EnumFieldNotDefineException(e.getMessage());
        }catch (Exception e) {
            throw new FormException(String.format("表单【%s】枚举异常: 【%s】", formBean.getFormName(), e.getMessage()));
        }
    }

    /**
     * 根据表单编码和枚举项名称和枚举数字值获取表单枚举项
     *
     * @param formCode
     * @param fieldDisplay
     * @param enumItemVal
     * @return
     * @description:
     * @author: huangjin
     * @time: 2025/4/1 16:06
     */
    public static CtpEnumItem getEnumItemByFormCodeAndFieldDisplayAndEnumItemVal(String formCode, String fieldDisplay, String enumItemVal) {
        preLoad();
        Assert.notBlank(enumItemVal, fieldDisplay + "枚举项值不能为空");
        FormBean formBean = null;
        try {
            formBean = cap4FormManager.getFormByFormCode(formCode);
            Assert.notNull(formBean, "{} 表单定义为空", formCode);
            return getEnumItemByFormBeanAndFieldDisplayAndEnumItemVal(formBean, fieldDisplay, enumItemVal);
        } catch (BusinessException e) {
            throw new FormException(e);
        }
    }

    /**
     * 根据表单编码和枚举项名称和枚举数字值获取表单枚举项
     *
     * @param formBean
     * @param fieldDisplay
     * @param enumItemVal
     * @return
     * @description:
     * @author: huangjin
     * @time: 2025/4/1 16:06
     */
    public static CtpEnumItem getEnumItemByFormBeanAndFieldDisplayAndEnumItemVal(FormBean formBean, String fieldDisplay, String enumItemVal) {
        Assert.notBlank(enumItemVal, fieldDisplay + "枚举项值不能为空");
        preLoad();
        try {

            List<CtpEnumItem> enumItemList = getEnumItemsByFormCodeAndFieldDisplay(formBean, fieldDisplay);
            List<CtpEnumItem> matchEnumItemList = enumItemList.stream().filter(ctpEnumItem -> enumItemVal.equals(ctpEnumItem.getValue())).collect(Collectors.toList());
            Assert.notEmpty(matchEnumItemList, "{},{} 枚举项不存在", fieldDisplay, enumItemVal);
            Assert.isTrue(matchEnumItemList.size() == 1, "{},{} 枚举项不唯一", fieldDisplay, enumItemVal);
            return matchEnumItemList.get(0);
        } catch (EnumFieldNotFoundException e) {
            throw new EnumFieldNotFoundException(e.getMessage());
        }
        catch (Exception e) {
            throw new FormException(String.format("%s 枚举异常", fieldDisplay));
        }
    }


    public static FormDic getFormDic(String dicCode, String enumItemVal) throws BusinessException {
        preLoad();
        String formDicBillDsi = AppContext.getSystemProperty("huasun.formDicBillDsi");
        if (StringUtils.isNotBlank(formDicBillDsi)) {
            CAP4FormManager cap4FormManager = (CAP4FormManager) AppContext.getBean("cap4FormManager");
            FormBean dicFormBean = cap4FormManager.getFormByFormCode(formDicBillDsi);
            FormFieldBean enumFieldBean = dicFormBean.getFieldBeanByDisplay("枚举编码");
            Cap4Where where = new Cap4Where().eq(enumFieldBean.getName(), dicCode);
            List<FormDataMasterBean> formDataMasterBeans = CAP4FormDataManagerExt.selectMasterDataList(new FlipInfo(1, 2), dicFormBean, null, where);
            Assert.notEmpty(formDataMasterBeans, "未找到【{}】档案字典", dicCode);
            Assert.isTrue(formDataMasterBeans.size() == 1, "档案字典【{}】不唯一", dicCode);
            FormTableBean subBean = CAP4FormKit.getSubTableBeanByDisplay(dicFormBean, "枚举值明细表");
            for (FormDataSubBean subData : formDataMasterBeans.get(0).getSubData(subBean.getTableName())) {
                String val = CAP4FormKit.getFieldValue(subData, "枚举值", String.class);
                String name = CAP4FormKit.getFieldValue(subData, "枚举值显示名称", String.class);
                if (enumItemVal.equals(val)){
                    FormDic formDic = new FormDic();
                    formDic.setLabel(name);
                    formDic.setValue(val);
                    return formDic;
                }
            }
            throw new BusinessException(String.format("档案字典值【%s】不存在",  enumItemVal));
        }
        throw new BusinessException("huasun.formDicBillDsi 未配置");
    }

    public static class FormDic {

        private String label;

        private String value;

        public String getLabel() {
            return label;
        }

        public void setLabel(String label) {
            this.label = label;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }
    }
}
